package timebetween;

/**
 * Created by 5406160@qq.com on LiBoWen 李博闻.
 *
 * @ClassName : PeriodDemo
 * @Author : 54061
 * @Date: 2022/2/12 14:06
 */
import java.time.LocalDate;
import java.time.Period;

public class PeriodDemo {
    public static void main(String[] args) {
        //创建2个时间对象
        LocalDate now = LocalDate.now();
        LocalDate birthDate = LocalDate.of(1990, 1, 1);

        //获取时间间隔对象
        Period between = Period.between(birthDate, now);

        System.out.println("between = " + between);//P32Y22D

        //Period类中有一个getDays() : 猜测获取间隔的天数
        int days = between.getDays();
        System.out.println("days = " + days);
    }
}
